package fr.emn.nuitinfo.model.validator;

public class AnswerChecker {

    public static String TO_REPLACE = "[`~!@#$%\\^&*\\(\\)_+\\[\\]\\\\;\',./{}|:\"<>?\\-€µ]";
    public static int RATE = 80;
    
    public static boolean checkAnswer(String typedAnswer, String[] expectedAnswers) {
	boolean isConform = false;
	
	for (String ans : expectedAnswers) {
	    isConform = isConform || (checkStrings(ans, typedAnswer));
	}
	
	return isConform;
    }
    
    public static boolean checkStrings(String reponseAttendue, String reponseSaisie) {
	// Nettoyage des string
	String repAttendue = reponseAttendue.toLowerCase().replaceAll(TO_REPLACE, "").replace(" ", "");
	String repSaisie = reponseSaisie.toLowerCase().replaceAll(TO_REPLACE, "").replace(" ", "");
	//System.out.println(repAttendue);
	
	// Calcul du taux de ressemblance
	if(Diff.tauxRessemblance(repAttendue, repSaisie) > RATE) {
	    return true;
	}
	else {
	    return false;
	}
    }
    
//    public static void main(String[] args) {
//	System.out.println(checkStrings("Notre-Dame De Paris", "notre damgezze de$paris"));
//    }
}
